package Hot100.leetcode.editor.cn.code.矩阵;
//Java：搜索二维矩阵 II
public class SearchA2dMatrixIi{
    public static void main(String[] args) {
        Solution solution = new SearchA2dMatrixIi().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        //从右上角利用性质开始排除
        int i = 0;
        int j = matrix[0].length -1;
        while(i < matrix.length &&  j >= 0){
            if(matrix[i][j] == target){
                return true;
            } else if (matrix[i][j] < target) {//小于整行排除
                i++;
            }else {
                j--;//大于的话整列排除
            }
        }

        return false;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}